package org.huawei260.TiKu.ODsuanfa;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;
public class A_2023A_3802__回溯硬件产品销售方案 {// python 83.3%

//	public class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);

			int amount = Integer.parseInt(sc.nextLine());

			String str = sc.nextLine();
			Integer[] prices =
				Arrays.stream(str.substring(1, str.length() - 1).split(", "))
					.map(Integer::parseInt)
					.toArray(Integer[]::new);

			System.out.println(getResult(amount, prices));
		}

		public static String getResult(int amount, Integer[] prices) {
			ArrayList<String> res = new ArrayList<>();
			LinkedList<Integer> path = new LinkedList<>();

			dfs(amount, prices, 0, 0, path, res);
			return res.toString();
		}

		public static void dfs(
			int total,
			Integer[] arr,
			int index,
			int sum,
			LinkedList<Integer> path,
			ArrayList<String> res) {
			if (sum >= total) {
				if (sum == total) res.add(path.toString());
				return;
			}

			for (int i = index; i < arr.length; i++) {
				path.addLast(arr[i]);
				dfs(total, arr, i, sum + arr[i], path, res);
				path.removeLast();
			}
		}
	}

	/*
	amount = int(input())
prices = eval(input())


def dfs(total, arr, index, sum, path, res):
    if sum >= total:
        if sum == total:
            res.append(path[:])
        return

    for i in range(index, len(arr)):
        path.append(arr[i])
        dfs(total, arr, i, sum + arr[i], path, res)
        path.pop()


res = []
dfs(amount, prices, 0, 0, [], res)
print(res)
	 */